package com.eastfair.pay.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 交易订单 支付状态
 * </p>
 *
 * @author fwl
 * @date 2023-03-22
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "TransactionOrderOrderStatusEnum", description = "订单状态:#{PAYING:支付中;UNPAY:未付款;PAYED:已付款;PARTPAY:部分分款;REFUNDING:退款中;REFUNDED:已退款-枚举")
public enum TransactionOrderOrderStatusEnum implements BaseEnum {

    /**
     * PAYING="支付中"
     */
    PAYING("支付中"),
    /**
     * UNPAY="未付款"
     */
    UNPAY("未付款"),
    /**
     * PAYED="已付款"
     */
    PAYED("已付款"),
    /**
     * PARTPAY="部分分款"
     */
    PARTPAY("部分分款"),
    /**
     * REFUNDING="退款中"
     */
    REFUNDING("退款中"),
//    /**
//     * CANCEL="作废"
//     */
//    CANCEL("作废"),
    /**
     * REFUNDED="已退款"
     */
    REFUNDED("已退款"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static TransactionOrderOrderStatusEnum match(String val, TransactionOrderOrderStatusEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static TransactionOrderOrderStatusEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(TransactionOrderOrderStatusEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "PAYING,UNPAY,PAYED,PARTPAY,REFUNDING,REFUNDED", example = "PAYING")
    public String getCode() {
        return this.name();
    }

}
